<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>

</head>
<body>
<input type="button" value="点我" id="btn">
<input type="button" value="点我" id="btn2">
<script>

    var foo = function (){
        alert('匿名函数');
    }

    function foo2(){
        alert('具名函数')
    }

    //调用的方式相同
//    foo();
//    foo2();


    //都可以被赋值
    var aa = foo;
    var bb = foo2;
    aa();
    bb();


    var btn = document.getElementById('btn');
    btn.onclick = foo;
    btn.onclick = foo2;


</script>
</body>
</html>